05 Data processing
BCC/BIN16 and BIN8 bit data addition, subtraction and exclusive check
BCC (P)
Specify the calculation method of BCC in (S1), specify the destination start address in (S2), and specify the destination data length in (S3), and then store the operation result in the device specified in (D).
- [BCC (S1) (S2) (S3) (D)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (S1) | 16-bit constant or the calculation method of 16-bit regions (block check code) | 0 to 2 | BIN16 bit | ANY16_S |
| (S2) | Calculate the initial 16-bit regions of BCC | - | BIN16 bit | ANY16_S |
| (S3) | 16-bit constant or 16-bit regions (specify the number of bytes calculated by BCC) | 0 to 32767 | BIN16 bit | ANY16_S |
| (D) | Stores 16-bit regions of BCC results | - | BIN16 bit | ANY16_S |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | ||||||||||
| KnX | KnY | KnM | KnS | T | C | D | R | SD | K | H | [D] | XXP | ||
| BCC | (S1) | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
| (S2) | ● | ● | ● | ● | ● | ● | ● | |||||||
| (S3) | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | |
| (D) | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||||
Features
According to the calculation method specified by S1, starting from the 16-bit data specified by S2, calculate the ASCII block check code (BCC) of the number of bytes specified by S3, and then store the result of BCC code in the low byte of 16-bit data specified by D.
S1: Specify the calculation method of BCC.
K0: Addition operation
K1: Subtraction operation
K2: Exclusive or operation
S2 and s3: Specify the destination data
For example, if the destination is the 12 bytes data starting from D0, the settings are as below.
S2: D0
S3: K12 (specify the data by decimal)
The modes used in the calculation of this instruction are 16-bit conversion mode and 8-bit conversion mode. For the actions of each mode, refer to the followings.
(1) 16-bit conversion mode (When SM161 is OFF)
Calculate the high 8-bit (byte) and low 8-bit (byte) of device that started from (S2) and specify the byte length by (S3), and store the low 8-bit of device specified by (D). The conversion result is as below.

(2) 8-bit conversion mode (When SM161 is ON)
Calculate the low 8-bit (byte) of device that started from (S2) and specify the byte length by (S3), and store the low 8-bit of device specified by (D). The conversion result is as below.

Error code
| Error code | Content |
| 4084H | The read application instructions (S1) and (S3) input the data that exceeds the specified range |
| 4085H | The device specified in the read application instructions (S1), (S2) and (S3) exceeds the corresponding device range |
| 4086H | The device specified in the write application instruction (D) exceeds the corresponding device range |
Example

When the trigger M0 is ON, calculate the a block check code (BCC) of 12-bit bytes of ASCII data starting from data register D0 by “exclusive or operation”. The block check code (BCC) is stored in the low bit byte of data register D6.
Application example
In the example ,calculate the BCC code and send as information after adding to the string “%01→RC”.
The data transmission is carried out in the form of ASCII codes.
CC calculations use logical exclusive OR, addition, and subtraction.
The information is stored as follows:
| Data register | D6 | D2 | D1 | D0 |
| ASCII hexadecimal code | 4 3 5 2 | 2 3 3 1 | 3 0 2 5 | |
| ASCII code | C R | # 1 | 0 % |
D6: BCC check code
D2 to D0: 6 byte
BCC instruction is as below:

S1(K2): logic exclusive OR
S2(D0): The start of destination data
S3(K6): destination data lengt
D(D6): calculation result
Execution or operation
| a | b | OR result |
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
After the execution BCC code is stored in the last byte of D6.
How to calculate block check code (BCC)
Calculate block check code (BCD) with XOR for each ASCII code.

BCC code
| ASCII hexadecimal code | 1 | 6 |
| ASCII binary code | 0 0 0 1 | 0 1 1 0 |
The calculation result is stored in the low bit byte of D6
MAX/BIN16 bit the maximum value of 16-bit data
MAX (P)
Specify the destination start address in (S1), and specify the destination end address in (S2), and then store the operation result in the device specified in (D).
- [MAX (S1) (S2) (D)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (S1) | Device that stores the start address when getting the max data | -32768 to 32767 | Signed BIN16 | ANY16_S |
| (S2) | Device that stores the end address when getting the max data | -32768 to 32767 | Signed BIN16 | ANY16_S |
| (D) | Stores the max value between the device data of (S1) and (S2) | -32768 to 32767 | Signed BIN16 | ANY16_S |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | ||||
| T | C | D | R | SD | [D] | XXP | ||
| MAX | (S1) | ● | ● | ● | ● | ● | ● | ● |
| (S2) | ● | ● | ● | ● | ● | ● | ● | |
| (D) | ● | ● | ● | ● | ● | ● | ● | |
Error code
Features
Use the BIN16 bit data specified in (S1) as the start address, and use the BIN16 bit data specified in (S2) as the end address to get the maximum value between the device of (S1) and (S2).
| Error code | Content |
| 4084H | The read application instructions (S1) and (S2) input the data that exceeds the specified range |
| 4085H | The device specified in the read application instructions (S1) and (S2) exceeds the device range |
| 4086H | The device specified in the write application instruction (D) exceeds the device range |
| 4093H | The specified ranges (S1) and (S2) are not the same device |
| 4094H | The sequence of specified ranges (S1) and (S2) is abnormal |
Example

Use (D1) as the start address, and use (D5) as the end address to get the max value between them and store the result in (D6). As the figure above, the max value between (D1) and (D5) is the value in (D3) which is stored in (D6) for output.
DMAX/BIN32 bit the maximum value of 32-bit data
DMAX (P)
Specify the destination start address in (S1), and specify the destination end address in (S2), and then store the operation result in the device specified in (D).
- [DMAX (S1) (S2) (D)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (S1) | Device that stores the start address when getting the max data | -2147483648 to 2147483647 | Signed BIN32 | ANY32_S |
| (S2) | Device that stores the end address when getting the max data | -2147483648 to 2147483647 | Signed BIN32 | ANY32_S |
| (D) | Stores the max value between the device data of (S1) and (S2) | -2147483648 to 2147483647 | Signed BIN32 | ANY32_S |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | ||||||
| T | C | D | R | SD | LC | HSC | [D] | XXP | ||
| DMAX | (S1) | ● | ● | ● | ● | ● | ● | ● | ● | ● |
| (S2) | ● | ● | ● | ● | ● | ● | ● | ● | ● | |
| (D) | ● | ● | ● | ● | ● | ● | ● | ● | ● | |
Features
Use the BIN32 bit data specified in (S1) as the start address, and use the BIN32 bit data specified in (S2) as the end address to get the maximum value between the device of (S1) and (S2).
✎Note
1. The devices specified by (S1) and (S2) should be the same type. The type of device (D) that gets the results could be different.
2. The device size specified by (S1) can’t exceed the device size specified by (S2). For example, DMAX D1 D5 D10 works, but DMAX D5 D1 D10 doesn't.
Error code
| Error code | Content |
| 4084H | The read application instructions (S1) and (S2) input the data that exceeds the speicified range |
| 4085H | The device specified in the read application instructions (s1) and (S2) exceeds the device range |
| 4086H | The device specified in the write application instruction (D) exceeds the device range |
| 4093H | The specified ranges (S1) and (S2) are not the same device |
| 4094H | The sequence of specified ranges (S1) and (S2) is abnormal |
Example
Use (D1) as the start address, and use (D7) as the end address to get the max value between them and store the result in (D9). As the figure above, the max value between (D1) and (D7) is the value in (D7) which is stores in (D9) for output.

MIN/BIN16 bit the minimum value of 16-bit data
MIN (P)
Specify the destination start address in (S1), and specify the destination end address in (S2), and then store the operation result in the device specified in (D).
- [MIN (S1) (S2) (D)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (S1) | Device that stores the start address when getting the minimum data | -32768 to 32767 | Signed BIN16 | ANY16_S |
| (S2) | Device that stores the end address when getting the minimum data | -32768 to 32767 | Signed BIN16 | ANY16_S |
| (D) | Stores the minimum value between the device data of (S1) and (S2) | -32768 to 32767 | Signed BIN16 | ANY16_S |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | ||||
| T | C | D | R | SD | [D] | XXP | ||
| MIN | (S1) | ● | ● | ● | ● | ● | ● | ● |
| (S2) | ● | ● | ● | ● | ● | ● | ● | |
| (D) | ● | ● | ● | ● | ● | ● | ● | |
Features
Use the BIN16 bit data specified in (S1) as the start address, and use the BIN16 bit data specified in (S2) as the end address to get the maximum value between the device of (S1) and (S2).
✎Note
1. The devices specified by (S1) and (S2) should be the same type. The type of device (D) that gets the results could be different.
2. The device size specified by (S1) can’t exceed the device size specified by (S2). For example, MAX D1 D5 D10 works, but MAX D5 D1 D10 doesn't.
Error code
| Error code | Content |
| 4084H | The read application instructions (S1) and (S2) input the data that exceeds the specified range |
| 4085H | The device specified in the read application instructions (S1) and (S2) exceeds the device range |
| 4086H | The device specified in the write application instruction (D) exceeds the device range |
| 4093H | The specified ranges (S1) and (S2) are not the same device |
| 4094H | The sequence of specified ranges (S1) and (S2) is abnormal |
Example
Use (D1) as the start address, and use (D5) as the end address to get the max value between them and store the result in (D6). As the figure above, the max value between (D1) and (D5) is the value in (D3) which is stored in (D6) for output.

DMIN/BIN32 bit the minimum value of 32-bit data
DMIN (P)
Specify the destination start address in (S1), and specify the destination end address in (S2), and then store the operation result in the device specified in (D).
- [DMIN (S1) (S2) (D)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (S1) | Device that stores the start address when getting the minimum data | -2147483648 to 2147483647 | Signed BIN16 | ANY16_S |
| (S2) | Device that stores the end address when getting the minimum data | -2147483648 to 2147483647 | Signed BIN16 | ANY16_S |
| (D) | Stores the minimum value between the device data of (S1) and (S2) | -2147483648 to 2147483647 | Signed BIN16 | ANY16_S |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | ||||
| T | C | D | R | SD | [D] | XXP | ||
| DMIN | (S1) | ● | ● | ● | ● | ● | ● | ● |
| (S2) | ● | ● | ● | ● | ● | ● | ● | |
| (D) | ● | ● | ● | ● | ● | ● | ● | |
Features
Use the BIN32 bit data specified in (S1) as the start address, and use the BIN32 bit data specified in (S2) as the end address to get the maximum value between the device of (S1) and (S2).
✎Note
1. The devices specified by (S1) and (S2) should be the same type. The type of device (D) that gets the results could be different.
2. The device size specified by (S1) can’t exceed the device size specified by (S2). For example, MAX D1 D5 D10 works, but MAX D5 D1 D10 doesn't.
Error code
| Error code | Content |
| 4084H | The read application instructions (S1) and (S2) input the data that exceeds the specified range |
| 4085H | The device specified in the read application instructions (S1) and (S2) exceeds the device range |
| 4086H | The device specified in the write application instruction (D) exceeds the device range |
| 4093H | The specified ranges (S1) and (S2) are not the same device |
| 4094H | The sequence of specified ranges (S1) and (S2) is abnormal |
Example
Use (D1) as the start address, and use (D5) as the end address to get the max value between them and store the result in (D6). As the figure above, the max value between (D1) and (D5) is the value in (D3) which is stored in (D6) for output.

ANS/alarm settings
ANS(P)
Used to set alarm instructions.
-[ANS (S) (N) (D)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (S) | Timer number for judging time | - | Signed BIN 16 bit | ANY16 |
| (N) | Data that judges time | 1 to 32767 | Signed BIN 16 bit | ANY16 |
| (D) | The set alarm device | - | Bit | ANY16_BOOL |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | |||||||||||
| S | KnX | KnY | KnM | KnS | T | C | D | R | SD | K | H | [D] | XXP | ||
| ANS | Parameter 1 | ● | ● | ● | |||||||||||
| Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||
| Parameter 3 | ● | ● | ● | ||||||||||||
Features
When the instruction input continues to be ON for the judgment time [(N)×100ms, timer (S)], set (D). If the instruction time turns off below the judgment time [(N)×100ms], the current value of the judgment timer (S) is reset, and (D) is not set. In addition, if the instruction input turns off, the judgment timer will be reset.


1. Judge the time ((N)X 100ms or less)
2. Judgment time or more (inclusive) ((N) X 100ms or more (inclusive))
Related device
| Devices | Name | Content |
| SM249 | Signal alarm is valid | After SM249 is ON, the following SM248 and SD249 act. |
| SM248 | Signal alarm action | SM249 is ON, when any one of the states S900 to S999 is active, SM248 is ON |
| SD249 | Signal alarm ON state minimum number | Save the smallest number of actions in S900 to S999. |
Error code
| Error code | Content |
| 4084H | The value specified in (N1) and (N2) exceeds the range of 0 to 32767 |
| The timer number is not in the range of T0 to T199. | |
| The signal alarm is not in the range of S900 to S999. | |
| 4085H | When the device specified in the read application instructions (S) and (N) exceeds the corresponding device range |
| 4086H | When the device specified in the write application instruction (D) exceeds the corresponding device range |
Example
The fault number is displayed by the signal alarm.
Monitoring is effective after SM249 is turned ON
As shown below, when you write a program for diagnosing external faults, such as monitoring the content of SM249 (the smallest number in the ON state), the smallest number in the ON state among S900 to S999 will be displayed. When multiple faults occur at the same time, the next fault number can be obtained after eliminating the fault with the smallest number.
Detect X1 for 2 seconds, turn ON, set S900
X4 is detected for 1 second, turn ON, set S901
SM248 will act after any one of S900 to S999 is ON, and the output fault display YY6 will act
Display the fault number to the D0 device
Through the external fault diagnosis program, use the reset button M0 to turn off the activated state. Each time M0 turns ON, the action status of the new number is set in turn, and the new number that is already ON is reset.

ANR/Alarm reset
ANR(P)
The instruction to reset the small number that is ON in the alarm.
-[ANR]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| No | No parameter setting | - | - | - |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | |||||||||||||||||||||||
| X | Y | M | S | SM | T(bit) | C(bit) | LC(bit) | HSC(bit) | D.b | KnX | KnY | KnM | KnS | T | C | D | R | SD | LC | HSC | K | H | E | [D] | XXP | ||
| ANR | No | No object device | |||||||||||||||||||||||||
Features
If the instruction input is ON, reset the active alarm in the alarm.
If multiple alarms are operating, reset the smaller number. If the input instruction is turned ON again, the next small number in the alarm that is operating will be reset.

Related device
| Devices | Name | Content |
| SM249 | Signal alarm is valid | After SM249 is ON, the following SM248 and SD249 act. |
| SM248 | Signal alarm action | SM249 is ON, when any one of the states S900 to S999 is active, SM248 is ON. |
| SD249 | Signal alarm ON state minimum number | Save the smallest number of actions in S900 to S999. |
✎Note:
If you use the ANR instruction, reset in sequence every cycle.
If the ANRP instruction is used, it will be executed in only one operation cycle.
Error code
No operation error.
Example
The fault number is displayed by the signal alarm.
As shown below, when you write a program for diagnosing external faults, such as monitoring the content of SM249 (the smallest number in the ON state), the smallest number in the ON state among S900 to S999 will be displayed. When multiple faults occur at the same time, the next fault number can be obtained after eliminating the fault with the smallest number.
Monitoring is effective after SM249 is turned ON
Detect X1 for 2 seconds, turn ON, set S900
X4 is detected for 1 second, turn ON, set S901
SM248 will act after any one of S900 to S999 is ON, and the output fault display YY6 will act
Display the fault number to the D0 device
Through the external fault diagnosis program, use the reset button M0 to turn off the activated state. Each time M0 turns ON, the action status of the new number is set in turn, and the new number that is already ON is reset.

BON/16-bit data bit judgment
BON(P)
Check whether the state of the BIN 16-bit data (N) bit of the device specified in (S) is ON or OFF, and output the result to the device specified in (D).
-[BON (S) (N) (D)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (S) | Data storage destination word device number | - | Signed BIN 16 bit | ANY16 |
| (D) | Bit device number of drive | - | Bit | ANY16_BOOL |
| (N) | The position of the bit to be judged | 0 to 15 | Signed BIN 16 bit | ANY16 |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | |||||||||||||||
| Y | M | S | SM | D.b | KnX | KnY | KnM | KnS | T | C | D | R | SD | K | H | [D] | XXP | ||
| BON | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | |||||
| Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | |||||||||
| Parameter 3 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||||||
Features
Check whether the state of the BIN 16-bit data (N) bit of the device specified in (S) is ON or OFF, and output the result to the device specified in (D).
If the above result is ON, then (D)=ON, if it is OFF, then (D)=OFF.
If a constant (K) is specified in the device specified in (S), it will be automatically converted to BIN.

Error code
| Error code | Content |
| 4084H | The data input in (N) exceeds the specified range of 0 to 15. |
| 4085H | When the device specified in the read application instructions (S) and (N) exceeds the corresponding device range |
| 4086H | When the device specified in the write application instruction (D) exceeds the corresponding device range |
Example

When n in D0 = the third bit is 1 (ON), M0 is set to 1 (ON).

DBON/32-bit data bit judgment
DBON(P)
Check whether the state of the BIN 32-bit data (N) bit of the device specified in (S) is ON or OFF, and output the result to the device specified in (D).
-[DBON (S) (N) (D)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (S) | Data storage destination word device number | - | Signed BIN 32 bit | ANY32 |
| (D) | Bit device number of drive | - | Bit | ANY32_BOOL |
| (N) | The position of the bit to be judged | 0 to 31 | Signed BIN 32 bit | ANY32 |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | |||||||||||||||||
| Y | M | S | SM | D.b | KnX | KnY | KnM | KnS | T | C | D | R | SD | LC | HSC | K | H | [D] | XXP | ||
| DBON | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | |||||
| Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | |||||||||||
| Parameter 3 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||||||
Features
Check whether the BIN 32-bit data (N) bit status of the device specified in (S) is ON or OFF, and output the result to the device specified in (D).
If the above result is ON, then (D)=ON, if it is OFF, then (D)=OFF.
If a constant (K) is specified in the device specified in (S), it will be automatically converted to BIN.

Error code
| Error code | Content |
| 4084H | The data input in (N) exceeds the specified range of 0 to 31. |
| 4085H | When the device specified in the read application instructions (S) and (N) exceeds the corresponding device range |
| 4086H | When the device specified in the write application instruction (D) exceeds the corresponding device range |
Example
When n in D0 = the third bit is 1 (ON), M0 is set to 1 (ON).


ENCO/Encode
ENCO(P)
Encode the data of the 2th (N)th power from (S) and store it in (D).
-[ENCO (S) (N) (D)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (S) | Start device for storing coded data | - | Bit/Signed BIN 16 bit | ANY_ELEMENTARY |
| (D) | Device number storing the encoding result | - | Signed BIN 16 bit | ANY_ELEMENTARY |
| (N) | Effective bit length | 0 to 8 | Signed BIN 16 bit | ANY16 |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | |||||||||||||||
| X | Y | M | S | SM | KnX | KnY | KnM | KnS | T | C | D | R | SD | K | H | [D] | XXP | ||
| ENCO | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||||||
| Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | |||||||||
| Parameter 3 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||||||
Features
The BIN value corresponding to the bit from 2 (N) bits of (S) to 1 is stored in (D).

When (N)=0, it will be no processing, and the content of the device specified in (D) will not change.
Bit devices are treated as 1 bit, and word devices are treated as 16 bits.
When multiple digits are 1, it will be processed at the upper position.
Error code
| Error code | Content |
| 4084H | In the bit device specification of (S), when (N) is other than 0 to 8. |
| In the word device specification of (S), when (N) is other than 0 to 4. | |
| When the data of 2(N) bits starting from (S) are all 0. | |
| 4085H | When the device specified in the read application instructions (S) and (N) exceeds the corresponding device range |
| 4086H | When the device specified in the write application instruction (D) exceeds the corresponding device range |
Example

When M20 is turned ON, the D0 device is 16 after encoding.
DECO/Decode
DECO(P)
Decode the lower (N) bits of the device specified in (S), and store the result in the 2 (N)th power of the device specified in (D).
-[DECO (S) (N) (D)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (S) | Decoded data or the device number storing the decoded data | - | Bit/Signed BIN 16 bit | ANY_ELEMENTARY |
| (D) | The start device storing the decoding result | - | Signed BIN 16 bit | ANY_ELEMENTARY |
| (N) | Effective bit length | 0 to 8 | Signed BIN 16 bit | ANY16 |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | |||||||||||||||
| X | Y | M | S | SM | KnX | KnY | KnM | KnS | T | C | D | R | SD | K | H | [D] | XXP | ||
| DECO | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | |
| Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||||||||
| Parameter 3 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||||||
Features
Turn ON the position of (D) corresponding to the BIN value specified in the lower (N) bit of (S).
When (N)=0, it will be no processing, and the content of the device specified in (D) will not change.
Bit devices are treated as 1 bit, and word devices are treated as 16 bits.

Error code
| Error code | Content |
| 4084H | In the bit device specification of (D), when (N) is other than 0 to 8. |
| In the word device specification of (D), when (N) is other than 0 to 4. | |
| 4085H | When the device specified in the read application instructions (S) and (N) exceeds the corresponding device range |
| 4086H | When the device specified in the write application instruction (D) exceeds the corresponding device range |
Example

When M20 is ON, M3 will be turned ON.
SUM/The ON bits of 16-bit data
SUM(P)
Store the total number of bits at 1 in the BIN 16-bit data of the device specified in (S) to the device specified in (D).
-[SUM (S) (D)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (S) | The device start number that counts the total number of bits at 1 | - | Signed BIN 16 bit | ANY16 |
| (D) | The device start number of the total number of storage bits | - | Signed BIN 16 bit | ANY16 |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | ||||||||||
| KnX | KnY | KnM | KnS | T | C | D | R | SD | K | H | [D] | XXP | ||
| SUM | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
| Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||||
Features
Store the total number of bits at 1 in the BIN 16-bit data of the device specified in (S) to the device specified in (D).
When the BIN 16-bit data of the device specified in (S) is all 0, the zero flag (SM153) turns on.
The total number of 1 (ON) is stored in BIN.
There are 8 in the example on the left.

Error code
| Error code | Content |
| 4085H | When the device specified in the read application instructions (S) exceeds the corresponding device range |
| 4086H | When the device specified in the write application instruction (D) exceeds the corresponding device range |
Example

When M0 is ON, the number of ON bits in D0 is counted and stored in D1. The value after D1 is executed is 4.
DSUM/The ON bits of 32-bit data
DSUM(P)
Store the total number of bits at 1 in the BIN 32-bit data of the device specified in (S) to the device specified in (D).
-[SUM (S) (D)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (S) | The device start number that counts the total number of bits at 1 | - | Signed BIN 32 bit | ANY32 |
| (D) | The device start number of the total number of storage bits | - | Signed BIN 32 bit | ANY32 |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | ||||||||||||
| KnX | KnY | KnM | KnS | T | C | D | R | SD | LC | HSC | K | H | [D] | XXP | ||
| DSUM | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
| Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||||
Features
Store the total number of bits at 1 in the BIN 32-bit data of the device specified in (S) to the device specified in (D).
When the BIN 32-bit data of the device specified in (S) is all 0 (OFF), the zero flag (SM153) turns on.
The total number of 1 (ON) is stored in BIN.
There are 16 in the example on the left.

✎Note: When the instruction input is OFF, the instruction will not be executed, and the output of the ON digits of the action will remain the same as before.
Error code
| Error code | Content |
| 4085H | When the device specified in the read application instructions (S) exceeds the corresponding device range |
| 4086H | When the device specified in the write application instruction (D) exceeds the corresponding device range |
Example

When M0 is ON, the number of ON bits in D0 is counted and stored in D10, and the value after D10 is executed is 4.
MEAN/Mean value of 16-bit data
MEAN(P)
The average value of the (n) point (16-bit) at the beginning of the soft component specified in (s) is calculated and the result is stored in (d).
-[MEAN (S) (D) (N)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (S) | The device start number storing the data for average calculation | - | Signed BIN 16 bit | ANY16 |
| (D) | The device start number storing the average value | - | Signed BIN 16 bit | ANY16 |
| (N) | Number of data or the device number storing the number of data | 1 to 32767 | Signed BIN 16 bit | ANY16 |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | ||||||||||
| KnX | KnY | KnM | KnS | T | C | D | R | SD | K | H | [D] | XXP | ||
| MEAN | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||
| Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||||
| Parameter 3 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | |
Features
Calculate the average value of the 16-bit data at (N) points starting from the device specified in (S) and store it in the device specified in (D).
The total is calculated from the algebraic sum and divided by (N).
The remainder is rounded off.

Error code
| Error code | Content |
| 4084H | The data input by (N) in the application instruction exceeds the specifiable range. N≤0 |
| 4085H | When the device specified in the read application instructions (S) and (N) exceeds the corresponding device range |
| 4086H | When the device specified in the write application instruction (D) exceeds the corresponding device range |
Example

Add the data of D0, D1, and D2 and save the value obtained after dividing by 3 in D10. The calculated average value is 6.
DMEAN/Mean value of 16-bit data
DMEAN(P)
The average value of the (n) point (32-bit) at the beginning of the soft component specified in (s) is calculated and the result is stored in (d).
-[DMEAN (S) (D) (N)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (S) | The device start number storing the data for average calculation | - | Signed BIN 32 bit | ANY32 |
| (D) | The device start number storing the average value | - | Signed BIN 32 bit | ANY32 |
| (N) | Number of data or the device number storing the number of data | 1 to 2147483647 | Signed BIN 32 bit | ANY32 |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | ||||||||||||
| KnX | KnY | KnM | KnS | T | C | D | R | SD | LC | HSC | K | H | [D] | XXP | ||
| DMEAN | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||
| Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||||
| Parameter 3 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | |
Features
Calculate the mean value of BIN 32-bit data at (N) points starting from the device specified in (S) and store it in the device specified in (D).
The total is calculated from the algebraic sum and divided by (N).
The remainder is rounded off.

✎Note: When the device number exceeds, (N) is handled as a smaller value within the allowable range.
Error code
| Error code | Content |
| 4084H | The data input in (N) exceeds the specifiable range. N≤0 |
| 4085H | When the device specified in the read application instructions (S) and (N) exceeds the corresponding device range |
| 4086H | When the device specified in the write application instruction (D) exceeds the corresponding device range |
Example

Add the data of D0, D2, and D4, and save the value obtained after dividing by 3 in D10 and D11, and the calculated average value is 6.
SQR/16-bit square root
SQR(P)
Calculate the square root of the BIN 16-bit data specified in (S), and store the calculation result in (D).
-[SQR (S) (D)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (S) | The data device storing for square root calculation | 0 to +32767 | Signed BIN 16 bit | ANY16 |
| (D) | The device storing the calculated square root | - | Signed BIN 16 bit | ANY16 |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | ||||
| D | R | SD | K | H | [D] | XXP | ||
| SQR | Parameter 1 | ● | ● | ● | ● | ● | ● | ● |
| Parameter 2 | ● | ● | ● | ● | ● | |||
Features
Calculate the square root of the BIN 16-bit data specified in (S), and store the calculation result in (D).

✎Note: The decimal point of operation result will be rounded off and become an integer. If rounding occurs, SM152 (borrow flag) turns ON.
When the operation result is really 0, SM153 (zero flag) turns ON.
Error code
| Error code | Content |
| 4084H | When a negative value is specified in (S). |
| 4085H | When the device specified in the read application instructions (S) exceeds the corresponding device range |
| 4086H | When the device specified in the write application instruction (D) exceeds the corresponding device range |
Example

The square root of D0 is stored in D2, and the value of D0 is 100, so the value of D2 is 10.
DSQR/32-bit square root
DSQR(P)
Calculate the square root of the BIN 32-bit data specified in (S), and store the calculation result in (D).
-[DSQR (S) (D)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (S) | The data device storing for square root calculation | 0 to 2147483647 | Signed BIN 32 bit | ANY32 |
| (D) | The device storing the calculated square root | - | Signed BIN 32 bit | ANY32 |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | ||||||
| D | R | SD | LC | HSC | K | H | [D] | XXP | ||
| DSQR | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● |
| Parameter 2 | ● | ● | ● | ● | ● | ● | ● | |||
Features
Calculate the square root of the BIN 32-bit data specified in (S) and store the calculation result in (D).

✎Note: The decimal point of operation result will be rounded off and become an integer. If rounding occurs, SM152 (borrow flag) turns ON.
When the operation result is really 0, SM153 (zero flag) turns on.
Error code
| Error code | Content |
| 4084H | When a negative value is specified in (S). |
| 4085H | When the device specified in the read application instructions (S) exceeds the corresponding device range |
| 4086H | When the device specified in the write application instruction (D) exceeds the corresponding device range |
Example

The square root of D0 is stored in D2, and the value of D0 is 110, so the value in the D2 soft component is 10 (the fractional part is discarded), and the borrow flag SM152 is turned ON.
WSUM/The sum value of 16-bit data
WSUM(P)
After adding all the BIN 16-bit data of point (n) starting from the device specified in (S), it is stored in the device specified in (D).
-[WSUM (S) (D) (N)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (S) | The device start number storing the data for sum value calculation | - | Signed BIN 16 bit | ANY16 |
| (D) | The device start number storing the sum value | - | Signed BIN 32 bit | ANY32 |
| (N) | Number of data | - | Signed BIN 16 bit | ANY16 |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | ||||||||||
| KnX | KnY | KnM | KnS | T | C | D | R | SD | K | H | [D] | XXP | ||
| WSUM | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ||||||
| Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||||
| Parameter 3 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | |
Features
After adding all the BIN 16-bit data of point (N) starting from the device specified in (S), it is stored in the device specified in (D).

Error code
| Error code | Content |
| 4084H | When a negative value is specified in (N). |
| 4085H | When the device specified in the read application instructions (S) and (N) exceeds the corresponding device range |
| 4086H | When the device specified in the write application instruction (D) exceeds the corresponding device range |
Example

When M0=ON, the total of 16-bit data of D0 to D2 is saved in [D100, D101], and the accounting result is 18.
DWSUM/The sum value of 32-bit data
DWSUM(P)
Add all the 32-bit BIN data of point (N) starting from the device specified in (S) and store it in the device specified in (D).
-[DWSUM (S) (D) (N)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (S) | The device start number storing the data for total value calculation | - | Signed BIN 32 bit | ANY32 |
| (D) | The device start number storing the total value | - | Signed BIN64 bit | ANY64 |
| (N) | Number of data | - | Signed BIN 32 bit | ANY32 |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | ||||||||||||
| KnX | KnY | KnM | KnS | T | C | D | R | SD | LC | HSC | K | H | [D] | XXP | ||
| DWSUM | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||||||
| Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||||
| Parameter 3 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | |
Features
Add all the 32-bit BIN data of point (n) starting from the device specified in (s) and store it in the device specified in (d).

✎Note: When the number of bits is specified in (D), the value of n ranges from 1 to 8, such as K8 (32-bit instructions, such as K8M0) without K16 (64-bit instructions).
Error code
| Error code | Content |
| 4084H | When a negative value is specified in (N). |
| 4085H | When the device specified in the read application instructions (S) and (N) exceeds the corresponding device range |
| 4086H | When the device specified in the write application instruction (D) exceeds the corresponding device range |
Example

When M0=ON, the total of 16-bit data of D0 to D2 is saved in [D100, D101], and the accounting result is 18.
SORT/16-bit data sorting
SORT
Sort the data rows in ascending order based on the group data of column (N3) in the BIN 16-bit data table (sorting source) of (N1×N2) points specified in (S) and store them in the specified in (D) (N1×N2) points in the BIN 16-bit data table (after sorting).
-[SORT (S) (N1) (N2) (D) (N3)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (S) | The start device number storing the data table | - | Signed BIN 16 bit | ANY16 |
| (N1) | Number of data (rows) | 1 to 32 | Signed BIN 16 bit | ANY16 |
| (N2) | Number of group data (columns) | 1 to 6 | Signed BIN 16 bit | ANY16 |
| (D) | The start device number storing the operation result | - | Signed BIN 16 bit | ANY16 |
| (N3) | The column number of the group data (column) as the sorting basis | - | Signed BIN 16 bit | ANY16 |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | ||||||||||
| KnX | KnY | KnM | KnS | T | C | D | R | SD | K | H | [D] | XXP | ||
| SORT | Parameter 1 | ● | ● | ● | ● | ● | ● | |||||||
| Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||
| Parameter 3 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||
| Parameter 4 | ● | ● | ● | ● | ● | ● | ||||||||
| Parameter 5 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||
Features
The BIN 16-bit data table (sorting source) of (N1×N2) points specified in (S), based on the group data of column (N3), sort the data rows in ascending order, and store them in (D). The (N1×N2) point of the BIN 16-bit data table (after sorting).
Take (N1)=K3, (N2)=K4 in the sort source as an example, the data table structure is as follows. In the case of a sorted data table, (S) should be replaced with (D).
| Number of groups (N2) ((N2)=K4) | |||||
| Column NO. 1 | Column NO. 2 | Column NO. 3 | Column NO. 4 | ||
| Management number | Height | Weight | Age | ||
| When the number of data (N1)=3 | Line NO.1 | (S) | (S) +3 | (S) +6 | (S) +9 |
| Line NO.2 | (S)+1 | (S) +4 | (S) +7 | (S) +10 | |
| Line NO.3 | (S)+2 | (S) +5 | (S) +8 | (s) +11 | |
Data alignment starts when instruction input is ON, data alignment ends after (N1) scan, instruction execution end flag SM229 is set to ON. According to the source data sorted as follows, an example of the operation is shown below. In addition, by putting serial numbers such as management numbers in the first column in advance, the original row number can be judged based on the content, which is very convenient.
| Number of groups (N2) ((N2)=K4) | |||||
| Column NO. 1 | Column NO. 2 | Column NO. 3 | Column NO. 4 | ||
| Management number | Height | Weight | Age | ||
| When the number of data (N1) = 5 | Line NO.1 | (S) | (S) +5 | (S) +10 | (S) +15 |
| 1 | 150 | 45 | 20 | ||
| Line NO.2 | (S)+1 | (S) +6 | (S) +11 | (S) +16 | |
| 2 | 180 | 50 | 40 | ||
| Line NO.3 | (S)+2 | (S) +7 | (S) +12 | (S) +17 | |
| 3 | 160 | 70 | 30 | ||
| Line NO.4 | (S) +3 | (S) +8 | (S) +13 | (S) +18 | |
| 4 | 100 | 20 | 8 | ||
| Line NO.5 | (S) +4 | (S) +9 | (S) +14 | (S) +19 | |
| 5 | 150 | 50 | 45 | ||
Press (N3)=K2 (column number 2) to execute the sorting result.
| Number of groups (N2) ((N2)=K4) | |||||
| Column NO.1 | Column NO.2 | Column NO.3 | Column NO.4 | ||
| Management number | Height | Weight | Age | ||
| When the number of data (N1) = 5 | Line NO.1 | (D) | (D) +5 | (D) +10 | (D) +15 |
| 4 | 100 | 20 | 8 | ||
| Line NO.2 | (D) +1 | (D) +6 | (D) +11 | (D) +16 | |
| 1 | 150 | 45 | 20 | ||
| Line NO.3 | (D) +2 | (D) +7 | (D) +12 | (D) +17 | |
| 5 | 150 | 50 | 45 | ||
| Line NO.4 | (D) +3 | (D) +8 | (D) +13 | (D) +18 | |
| 3 | 160 | 70 | 30 | ||
| Line NO.5 | (D) +4 | (D) +9 | (D) +14 | (D) +19 | |
| 2 | 180 | 50 | 40 | ||
Press (N3)=K3 (column number 3) to execute the sorting result.
| Number of groups (N2) ((N2)=K4) | |||||
| Column NO.1 | Column NO.2 | Column NO.3 | Column NO.4 | ||
| Management number | Height | Weight | Age | ||
| When the number of data (N1) = 5 | Line NO.1 | (D) | (D) +5 | (D) +10 | (D) +15 |
| 4 | 100 | 20 | 8 | ||
| Line NO.2 | (D) +1 | (D) +6 | (D) +11 | (D) +16 | |
| 1 | 150 | 45 | 20 | ||
| Line NO.3 | (D) +2 | (D) +7 | (D) +12 | (D) +17 | |
| 2 | 180 | 50 | 40 | ||
| Line NO.4 | (D) +3 | (D) +8 | (D) +13 | (D +18 | |
| 5 | 150 | 50 | 45 | ||
| Line NO.5 | (D) +4 | (D) +9 | (D) +14 | (D) +19 | |
| 3 | 160 | 70 | 30 | ||
✎Note: only ascending order is supported by SORT instruction .
Do not change the operand and data content during operation.
When executing again, the instruction input should be turned OFF once.
SORT instruction can drive at most one in the program.
When the same device is specified in (S) and (D), the source data is rewritten to the sorted data order. Please pay special attention not to change the content of (S) before the end of execution.
Error code
| Error code | Content |
| 4084H | When the value specified in (N1) exceeds the range of 1 to 32 |
| When the value specified in (N2) exceeds the range of 1 to 6 | |
| When the value specified in (N3) exceeds the range of 1 to n2 | |
| 4085H | When the device specified in read application instruction (S), (N1), (N2 )and (N3) exceeds the corresponding device range |
| 4086H | When the device specified in the write application instruction (D) exceeds the corresponding device range |
| 4087H | When the (D) parameter in the application instruction uses an unsupported device |
| 4089H | The number of application instructions exceeds the limit. |
Example
Refer to the function description example.

SORT2/16-bit data sorting
SORT2(P)
Sort the data rows in ascending or descending order based on the group data in column (N3), and store them in (D), based on the BIN 16-bit data table (sorting source) of (N1×N2) points specified in (S) In the BIN 16-bit data table (after sorting) of the specified (N1×N2) points.
-[SORT2 (S) (N1) (N2) (D) (N3)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (S) | The start device number storing the data table | - | Signed BIN 16 bit | ANY16 |
| (N1) | Number of data (rows) | 1 to 32 | Signed BIN 16 bit | ANY16 |
| (N2) | Number of group data (columns) | 1 to 6 | Signed BIN 16 bit | ANY16 |
| (D) | The start device number storing the operation result | - | Signed BIN 16 bit | ANY16 |
| (N3) | The column number of the group data (column) as the sorting basis | - | Signed BIN 16 bit | ANY16 |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | ||||||||||
| KnX | KnY | KnM | KnS | T | C | D | R | SD | K | H | [D] | XXP | ||
| SORT2 | Parameter 1 | ● | ● | ● | ● | ● | ● | |||||||
| Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||
| Parameter 3 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||
| Parameter 4 | ● | ● | ● | ● | ● | ● | ||||||||
| Parameter 5 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||
Features
Sort the data rows in ascending or descending order based on the group data in column (N3) and store them in (D) (N1×N2) point specified in the BIN 16-bit data table (after sorting).
Take (N1)=K3, (N2)=K4 in the sort source as an example, the data table structure is as follows. In the case of a sorted data table, (S) should be replaced with (D).
| When the number of groups (N2) (N2) = K4 | |||||
| Column NO.1 | Column NO.2 | Column NO.3 | Column NO.4 | ||
| Management number | Height | Weight | Age | ||
| When the number of data (N1)=3 | Line NO.1 | (S) | (S)+1 | (S) +2 | (S) +3 |
| Line NO.2 | (S) +4 | (S) +5 | (S) +6 | (S) +7 | |
| Line NO.3 | (S) +8 | (S) +9 | (S) +10 | (S) +100 | |
Sequence is set by the ON/OFF status of SM165
| Sort order setting instruction | |
| SM165=ON | Descending |
| SM165=OFF | Ascending |
Data alignment starts when instruction input is ON, data alignment ends after (N1) scan, instruction execution end flag SM229 is set to ON.
According to the source data sorted as follows, an example of the operation is shown below. In addition, by putting serial numbers such as management numbers in the first column in advance, the original row number can be judged based on the content, which is very convenient.
| When the number of groups (N2) (N2) = K4 | |||||
| Column NO.1 | Column NO.2 | Column NO.3 | Column NO.4 | ||
| Management number | Height | Weight | Age | ||
| When the number of data (N1) = 5 | Line NO.1 | (S) | (S)+1 | (S) +2 | (S) +3 |
| 1 | 150 | 45 | 20 | ||
| Line NO.2 | (S) +4 | (S) +5 | (S) +6 | (S) +7 | |
| 2 | 180 | 50 | 40 | ||
| Line NO.3 | (S) +8 | (S) +9 | (S) +10 | (S) +100 | |
| 3 | 160 | 70 | 30 | ||
| Line NO.4 | (S) +12 | (S) +13 | (S) +14 | (S) +15 | |
| 4 | 100 | 20 | 8 | ||
| Line NO.5 | (S) +16 | (S) +17 | (S) +18 | (S) +19 | |
| 5 | 150 | 50 | 45 | ||
Press (N3)=K2 (column number 2) to execute the sorting result (SM165=OFF in the case of ascending order)
| When the number of groups (N2) (N2) = K4 | |||||
| Column NO.1 | Column NO.2 | Column NO.3 | Column NO.4 | ||
| Management number | Height | Weight | Age | ||
| When the number of data (N1) = 5 | Line NO.1 | (D) | (D) +1 | (D) +2 | (D) +3 |
| 4 | 100 | 20 | 8 | ||
| Line NO.2 | (D) +4 | (D) +5 | (D) +6 | (D) +7 | |
| 1 | 150 | 45 | 20 | ||
| Line NO.3 | (D) +8 | (D) +9 | (D) +10 | (D) +100 | |
| 5 | 150 | 50 | 45 | ||
| Line NO.4 | (D) +12 | (D) +13 | (D) +14 | (D) +15 | |
| 3 | 160 | 70 | 30 | ||
| Line NO.5 | (D) +16 | (D) +17 | (D) +18 | (D) +19 | |
| 2 | 180 | 50 | 40 | ||
Press (N3)=K3 (column number 3) to execute the sorting result (SM165=ON in the case of ascending order)
| When the number of groups (N2) (N2) = K4 | |||||
| Column NO.1 | Column NO.2 | Column NO.3 | Column NO.4 | ||
| Management number | Height | Weight | Age | ||
| When the number of data (N1) = 5 | Line NO.1 | (D) | (D) +1 | (D) +2 | (D) +3 |
| 3 | 160 | 70 | 30 | ||
| Line NO.2 | (D) +4 | (D) +5 | (D) +6 | (D) +7 | |
| 2 | 180 | 50 | 40 | ||
| Line NO.3 | (D) +8 | (D) +9 | (D) +10 | (D) +100 | |
| 5 | 150 | 50 | 45 | ||
| Line NO.4 | (D) +12 | (D) +13 | (D) +14 | (D) +15 | |
| 1 | 150 | 45 | 20 | ||
| Line NO.5 | (D) +16 | (D) +17 | (D) +18 | (D) +19 | |
| 4 | 100 | 20 | 8 | ||
✎Note: Do not change the operand and data content during operation.
When executing again, the instruction input should be turned OFF once.
The SORT2 instruction can only be written in the program to drive 2 at most.
When the same device is specified in (S) and (D), the source data is rewritten to the sorted data order. Please pay special attention not to change the content of (S) before the end of execution.
Do not overlap the source data and the sorted data.

Error code
| Error code | Content |
| 4084H | When the value specified in (N1) exceeds the range of 1 to 32 |
| When the value specified in (N2) exceeds the range of 1 to 6 | |
| When the value specified in (N3) exceeds the range of 1 to n2 | |
| 4085H | When the device specified in read application instruction (S), (D), (N1), (N2 )and (N3) exceeds the corresponding device range |
| 4086H | When the device specified in the write application instruction (D) exceeds the corresponding device range |
| 4089H | The number of application instructions exceeded the limit. |
Example
Refer to the function description example.

DSORT2/32-bit data sorting
DSORT2(P)
Sort the data rows in ascending or descending order based on the group data of column (N3) in the BIN 32-bit data table (sorting source) of (N1×N2) points specified in (S) and store them in (D) The specified (N1×N2) point BIN 32-bit data table (after sorting).
-[DSORT2 (S) (N1) (N2) (D) (N3)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (S) | The start device number storing the data table | - | Signed BIN 32 bit | ANY32 |
| (N1) | Number of data (rows) | 1 to 32 | Signed BIN 32 bit | ANY32 |
| (N2) | Number of group data (columns) | 1 to 6 | Signed BIN 32 bit | ANY32 |
| (D) | The start device number storing the operation result | - | Signed BIN 32 bit | ANY32 |
| (N3) | The column number of the group data (column) as the sorting basis | - | Signed BIN 32 bit | ANY32 |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | ||||||||||||
| KnX | KnY | KnM | KnS | T | C | D | R | SD | LC | HSC | K | H | [D] | XXP | ||
| DSORT2 | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | |||||||
| Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||
| Parameter 3 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||
| Parameter 4 | ● | ● | ● | ● | ● | ● | ● | ● | ||||||||
| Parameter 5 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||
Features
Sort the data rows in ascending or descending order based on the group data in the (N3) column of the (N1×N2) point BIN 32-bit data table (sorting source) specified in (S), and store to (d) (N1×N2) specified in the BIN 32-bit data table (after sorting).
Take (N1)=K3, (N2)=K4 in the sort source as an example, the data table structure is as follows. In the case of a sorted data table, (S) should be replaced with (D).
| When the number of groups (N2) (N2) = K4 | |||||
| Column NO.1 | Column NO.2 | Column NO.3 | Column NO.4 | ||
| Management number | Height | Weight | Age | ||
| When the number of data (N1)=3 | Line NO.1 | (S)+1, (S) | (S)+3, (S)+2 | (S)+5, (S)+4 | (S) +7, (S) +6 |
| Line NO.2 | (S) +9, (S) +8 | (S)+11, (S)+10 | (S) +13, (S) +12 | (S) +15, (S) +14 | |
| Line NO.3 | (S) +17, (S) +16 | (S) +19, (S) +18 | (S) +21, (S) +20 | (S) +23, (S) +22 | |
Sequence is set by the ON/OFF status of SM165
| Sort order setting instructions | |
| SM165=ON | Descending |
| SM165=OFF | Ascending |
Data alignment starts when instruction input is ON, data alignment ends after (n1) scan, instruction execution end flag SM229 is set to ON.
According to the source data sorted as follows, an example of the operation is shown below. In addition, by putting serial numbers such as management numbers in the first column in advance, the original row number can be judged based on the content, which is very convenient.
| When the number of groups (N2) (N2) = K4 | |||||
| Column NO.1 | Column NO.2 | Column NO.3 | Column NO.4 | ||
| Management number | height | body weight | age | ||
| When the number of data (N1) = 5 | Line NO.1 | (S)+1, (S) | (S)+3, (S)+2 | (S)+5, (S)+4 | (S) +7, (S) +6 |
| 1 | 150 | 45 | 20 | ||
| Line NO.2 | (S) +9, (S) +8 | (S)+11, (S)+10 | (S) +13, (S) +12 | (S) +15, (S) +14 | |
| 2 | 180 | 50 | 40 | ||
| Line NO.3 | (S) +17, (S) +16 | (S) +19, (S) +18 | (S) +21, (S) +20 | (S) +23, (S) +22 | |
| 3 | 160 | 70 | 30 | ||
| Line NO.4 | (S) +25, (S) +24 | (S) +27, (S) +26 | (S) +29, (S) +28 | (S) +31, (S) +30 | |
| 4 | 100 | 20 | 8 | ||
| Line NO.5 | (S) +33, (S) +32 | (S) +35, (S) +34 | (S) +37, (S) +36 | (S) +39, (S) +38 | |
| 5 | 150 | 50 | 45 | ||
Press (N3)=K2 (column NO.2) to execute the sorting result (SM165=OFF in the case of ascending order)
| When the number of groups (N2) (N2) = K4 | |||||
| Column NO.1 | Column NO.2 | Column NO.3 | Column NO.4 | ||
| Management number | height | body weight | age | ||
| When the number of data (N1) = 5 | Line NO.1 | (S)+1, (S) | (S)+3, (S)+2 | (S)+5, (S)+4 | (S) +7, (S) +6 |
| 4 | 100 | 20 | 8 | ||
| Line NO.2 | (S) +9, (S) +8 | (S)+11, (S)+10 | (S) +13, (S) +12 | (S) +15, (S) +14 | |
| 1 | 150 | 45 | 20 | ||
| Line NO.3 | (S) +17, (S) +16 | (S) +19, (S) +18 | (S) +21, (S) +20 | (S) +23, (S) +22 | |
| 5 | 150 | 50 | 45 | ||
| Line NO.4 | (S) +25, (S) +24 | (S) +27, (S) +26 | (S) +29, (S) +28 | (S) +31, (S) +30 | |
| 3 | 160 | 70 | 30 | ||
| Line NO.5 | (S) +33, (S) +32 | (S) +35, (S) +34 | (S) +37, (S) +36 | (S) +39, (S) +38 | |
| 2 | 180 | 50 | 40 | ||
Press (N3)=K3 (column NO.3) to execute the sorting result (SM165=ON in the case of ascending order)
| When the number of groups (N2) (N2) = K4 | |||||
| Column NO.1 | Column NO.2 | Column NO.3 | Column NO.4 | ||
| Management number | height | body weight | age | ||
| When the number of data (N1) = 5 | Line NO.1 | (S)+1, (S) | (S)+3, (S)+2 | (S)+5, (S)+4 | (S) +7, (S) +6 |
| 3 | 160 | 70 | 30 | ||
| Line NO.2 | (S) +9, (S) +8 | (S)+11, (S)+10 | (S) +13, (S) +12 | (S) +15, (S) +14 | |
| 2 | 180 | 50 | 40 | ||
| Line NO.3 | (S) +17, (S) +16 | (S) +19, (S) +18 | (S) +21, (S) +20 | (S) +23, (S) +22 | |
| 5 | 150 | 50 | 45 | ||
| Line NO.4 | (S) +25, (S) +24 | (S) +27, (S) +26 | (S) +29, (S) +28 | (S) +31, (S) +30 | |
| 1 | 150 | 45 | 20 | ||
| Line NO.5 | (S) +33, (S) +32 | (S) +35, (S) +34 | (S) +37, (S) +36 | (S) +39, (S) +38 | |
| 4 | 100 | 20 | 8 | ||
✎Note: Do not change the operand and data content during operation.
When executing again, the instruction input should be turned OFF once.
The SORT2 instruction can only be written twice in the program.
When the same device is specified in (S) and (D), the source data is rewritten to the sorted data order. Please pay special attention not to change the content of (S) before the end of execution.
Do not overlap the source data and the sorted data.

Error code
| Error code | Content |
| 4084H | When the value specified in (N1) exceeds the range of 1 to 32 |
| When the value specified in (N2) exceeds the range of 1 to 6 | |
| When the value specified in (N3) exceeds the range of 1 to n2 | |
| 4085H | When the device specified in read application instruction (S), (D), (N1), (N2 )and (N3) exceeds the corresponding device range |
| 4086H | When the device specified in the write application instruction (D) exceeds the corresponding device range |
| 4089H | The number of application instructions exceeded the limit. |
Example
Refer to the function description example.

SWAP/16-bit data high and low byte swap
SWAP(P)
Swap the high and low 8-bit value of the device specified in (D).
-[SWAP (D)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (D) | Word device with high and low byte swap | - | Signed BIN 16 bit | ANY16 |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | |||||||
| KnY | KnM | KnS | T | C | D | R | SD | [D] | XXP | ||
| SWAP | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
Features
Convert the high and low 8-bit value of the device specified in (D).

Error code
| Error code | Content |
| 4085H | When the device specified in the read application instruction (D) exceeds the corresponding device range |
| 4086H | When the device specified in the write application instruction (D) exceeds the corresponding device range |
Example

When the rising edge of M0 is triggered, swap the low 8 bits and high 8 bits of D0 to get H8F2A.
DSWAP/32-bit data high and low byte swap
DSWAP(P)
The devices specified in (D) and (D)+1 will be converted to the high and low 8-bit values respectively.
-[DSWAP (D)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (D) | Word device with high and low byte swap | - | Signed BIN 32 bit | ANY32 |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | |||||||||
| KnY | KnM | KnS | T | C | D | R | SD | LC | HSC | [D] | XXP | ||
| DSWAP | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
Features
The devices specified in (D) and (D)+1 will be converted to the upper and lower 8-bit values respectively.

✎Note: If continuous execution instructions are used, conversion will be performed every scan cycle.
Error code
| Error code | Content |
| 4085H | When the device specified in the read application instruction (D) exceeds the corresponding device range |
| 4086H | When the device specified in the write application instruction (D) exceeds the corresponding device range |
Example

When the rising edge of M0 is triggered, the low 8 bits and the high 8 bits of D0 and D1 are swapped, and D0=H8F2A, D1=H3412 are obtained.

BTOW/Byte unit data merge
BTOW(P)
Combine the low 8 bits of (N) bytes of BIN 16-bit data stored after the device number specified in (S) into word units and store it after the device number specified in (D).
-[BTOW (S) (D) (N)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (S) | The start device that stores the data merging in byte units | - | Signed BIN 16 bit | ANY16 |
| (D) | The start device that stores the result of merging in byte units | - | Signed BIN 16 bit | ANY16 |
| (N) | Number of byte data merged | 0-32767 | Signed BIN 16 bit | ANY16 |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | ||||||||||
| KnX | KnY | KnM | KnS | T | C | D | R | SD | K | H | [D] | XXP | ||
| BTOW | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ||||||
| Parameter 2 | ● | ● | ● | ● | ● | ● | ● | |||||||
| Parameter 3 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | |
Features
After the device number specified in (s), the lower 8 bits of the 16-bit BIN data stored in (n) bytes are combined into word units and stored in the device number specified in (d) or later.
The upper 8 bits of (n) word data stored after the device number specified in (s) will be ignored. In addition, when (n) is an odd number, 0 is stored in the upper 8 bits of the device storing the (n)th byte of data.

£: the £th byte data;
(1): Ignore the high byte
*1: Carry below the decimal point.
Example
When (N)=5, the data up to the lower 8 bits of (S)+(S)+4 is stored in (D)+(D)+2.

(1): When (N)=5
(2): Change to 00H
By setting the number of bytes in (N), the range of byte data specified in (S) and the range of the device storing the combined data specified in (D) will be automatically determined.
When the number of bytes specified in (N) is 0, no processing is performed.
The upper 8 bits of the byte data storage device specified in (S) will be ignored, and the lower 8 bits will be the target.
Example
When the low 8 bits of D11 to D16 is stored in D12 to D14.

Even if the device range storing the data before merging overlaps the device rangestoring merged data, it will be handled as normal.
| Device range storing the data before merging | Device range for storing merged data |
| (S)+0 to (S)+(N)-1 | (D) to (D) + (N/2-1) |
Error code
| Error code | Content |
| 4084H | The value specified in (N) exceed range of 0 to 32767 |
| 4085H | When the device specified in the write application instruction (S),(D) and (N) exceeds the corresponding device range |
Example

When M0 is ON, the data of D20 to D25 is separated according to byte units, and then stored in D10 to D12.

WTOB/Byte unit data separation
WTOB(P)
After separating the BIN 16-bit data stored after the device number specified in (S) into (N) bytes, store it after the device number specified in (D).
-[WTOB (S) (D) (N)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (S) | The start device that stores the data separation in byte unit | - | Signed BIN 16 bit | ANY16 |
| (D) | The start device that stores the result of separation in byte unit | - | Signed BIN 16 bit | ANY16 |
| (N) | Number of byte data separated | 0-32767 | Signed BIN 16 bit | ANY16 |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | ||||||
| T | C | D | R | SD | K | H | [D] | XXP | ||
| WTOB | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ||
| Parameter 2 | ● | ● | ● | ● | ● | ● | ● | |||
| Parameter 3 | ● | ● | ● | ● | ● | ● | ● | |||
Features
After separating the BIN 16-bit data stored after the device number specified in (S) into (N) bytes, store it after the device number specified in (D).

- High byte;
- Low byte;
- High byte data;
- Low byte data;
- *1: Carry below the decimal point.
Example
In the case of (N)=5, store the data up to the lower 8 bits of (S) to (S)+2 in (D) to (D)+4:

- (N)=5 is ignored.
- (N)=5.
By setting the number of bytes in (N), the range of BIN 16-bit data specified in (S) and the range of the device storing the byte data specified in (D) will be automatically determined.
When the number of bytes specified in (N) is 0, no processing is performed.
00H is automatically stored in the upper 8 bits of the byte data storage device specified in (D).
Example
When D12 to D14 is stored in the low 8 bits of D11 to D16

Even if the device range storing the data before merging overlaps the device rangestoring merged data, it will be handled as normal.
| Device range storing the data before merging | Device range storing separated data |
| (S) to (S) + (N/2-1) | (D)+0 to (D)+(N)-1 |
Error code
| Error code | Content |
| 4084H | The value specified by (N) exceed the range of 0 to 32767 |
| 4085H | When the device specified in read application instruction (S) and (N) exceeds the corresponding device range |
| 4086H | When the device specified in the write application instruction (D) exceeds the corresponding device range |
Example

When M0 is ON, the data of D10 to D12 are separated according to byte units, and then stored in D20 to D25.

DIS/4-bit separation of 16-bit data
DIS(P)
Store the data of the low (N) bits (1 bit of 4 bits) of the BIN 16-bit data specified in (S) into the low 4-bit of the (N) point starting from the device specified in (D).
-[DIS (S) (D) (N)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (S) | The start device storing the data before separation | - | Signed BIN 16 bit | ANY16 |
| (D) | The start device storing separated data | - | Signed BIN 16 bit | ANY16 |
| (N) | Separation number (0 means no processing) | 0-4 | Signed BIN 16 bit | ANY16 |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | ||||||||||
| KnX | KnY | KnM | KnS | T | C | D | R | SD | K | H | [D] | XXP | ||
| DIS | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
| Parameter 2 | ● | ● | ● | ● | ● | ● | ● | |||||||
| Parameter 3 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | |
Features
Store the low-(N) bit (1 bits of 4 bits) of the BIN 16-bit data specified in (S) in the low 4-bit of the (N) point starting from the device specified in (D).

The hig-12 bit of the point (N) starting from the device specified in (S) will become 0.
When (N)=0, it will become no processing, and the content of point (N) starting from the device of (D) will not change.
Error code
| Error code | Content |
| 4084H | The data in (N) exceed the range of 0 to 4 |
| 4085H | When the device specified in read application instruction (S) and (N) exceeds the corresponding device range |
| 4086H | When the device specified in the write application instruction (D) exceeds the corresponding device range |
Example

When M0 is ON, D0 is separated every 4 bits and stored in D10 to D12. The result is D10 = HF, D11 = H8, D12 = HA.
UNI/4-bit combination of 16-bit data
UNI(P)
Combine the low 4 bits of the BIN 16-bit data of point (N) starting from the device specified in (S) into the BIN 16-bit device specified in (D).
-[UNI (S) (D) (N)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (S) | The start device storing the data before merging | - | Signed BIN 16 bit | ANY16 |
| (D) | The start device storing the merged data | - | Signed BIN 16 bit | ANY16 |
| (N) | Number of merger | 0-4 | Signed BIN 16 bit | ANY16 |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | ||||||||||
| KnX | KnY | KnM | KnS | T | C | D | R | SD | K | H | [D] | XXP | ||
| UNI | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ||||||
| Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||||
| Parameter 3 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | |
Features
Combine the low 4 bits of the BIN 16-bit data at point (N) starting from the device specified in (S) into the BIN 16-bit device specified in (D).

The high (4-N) bits of the device specified in (D) will become 0.
When (N)=0, it will become no processing, and the content of the device in (D) will not change.
Error code
| Code | Content |
| 4084H | The data in (N) exceed the range of 0 to 4 |
| 4085H | When the device specified in read application instruction (S) and (N) exceeds the corresponding device range |
| 4086H | When the device specified in the write application instruction (D) exceeds the corresponding device range |
Example

When M0 is ON, the low 4 bits of D0 to D3 are combined and stored in D10, the value is H236F.
ZRST/Data batch reset
ZRST(P)
Perform a batch reset between the devices specified in (d1) and (d2) of the same type. It is used when interrupting operation, performing initial operation, or resetting control data.
-[ZRST (d1) (d2)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (d1) | The start bit or word device number of batch reset | - | Bit/Signed BIN 16 bit | ANY_ELEMENTARY |
| (d2) | The final bit or word device number of batch reset | - | Bit/Signed BIN 16 bit | ANY_ELEMENTARY |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | ||||||||||||||
| Y | M | S | SM | KnX | KnY | KnM | KnS | T | C | D | R | SD | LC | HSC | [D] | XXP | ||
| ZRST | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
| Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | |
Features
Perform batch reset between the devices specified in (d1) and (d2) of the same type.
When (d1) and (d2) are bit devices, write OFF (reset) in the entire device range of (d1) to (d2).

When (d1) and (d2) are word devices, write K0 in the entire device range of (d1) to (d2).

As a separate reset instruction for the device, the RST instruction can be used for bit devices or word devices.
Reset M0
Reset D0
Reset the current value of T0

The batch write instruction of constant (for example: K0) has FMOV (P) instruction, which can write 0 to word devices (including bit device specification).
Write K0 in D0 to D99.

✎Note: Please specify the same type number for (d1) and (d2), and make (d1) number <(d2) number. When (d1) number ≥ (d2) number, only 1 point will be reset for the device specified in (d1).
ZRST(P) instruction is a 16-bit instruction, which can specify (LC) and (HSC) devices for (d1) and (d2).
Error code
| Error code | Content |
| 4084H | When the device type specified in (d1) is different from the device type specified in (d2). |
| 4085H | When the device specified in the read application instruction (d1) and (d2) exceeds the corresponding device range |
| 4086H | When the device specified in the write application instruction (d1) exceeds the corresponding device range |
Example

The function of this Circuit program instruction is to set the value of the D0 to D100 device to 0.
ZSET/Data batch set
ZSET(P)
Perform a batch set between the devices specified in (d1) and (d2) of the same type.

Content, range and data type
| Parameter | Content | Range | Data type | Data type(label) |
| (d1) | The start bit device number of batch set | - | Bit | ANY_BOOL |
| (d2) | The final bit device number of batch set | - | Bit | ANY_BOOL |
Device used
| Instruction | Parameter | Devices | Offset modification | ||||
| Y | M | S | SM | D.b | [D] | ||
| ZSET | Parameter 1 | ● | ● | ● | ● | ● | ● |
| Parameter 2 | ● | ● | ● | ● | ● | ● | |
Features
·Perform a batch set between the devices specified in (d1) and (d2) of the same type.
·Write ON (set) in the entire device range of (d1) to (d2)

·As a separate set instruction for the device, the SET instruction can be used for bit devices.
Set M1
Set Y1
Set S1

Error code
| Error code | Content |
| 4084H | When the device type specified in (d1) is different from the device type specified in (d2). |
| 4085H | When the device specified in the read application instruction (d1) and (d2) exceeds the corresponding device range |
| 4086H | When the device specified in the write application instruction (d1) exceeds the corresponding device range |
| 4087H | When the device type specified in (d1) and (d2) are not bit device. |
Example

The function of this LAD instruction is to set the value of the M1 to M4 device to ON.
CRC/cyclic redundancy check instruction
CRC(P)
Calculate the CRC (Cyclic Redundancy Check) value, which is one of the error checking methods used in communications. In addition to CRC, error checking methods include parity and
Sum check (checksum), calculate horizontal parity check value and sum check value can use CCD(P) instruction . And this instruction is used in the generator polynomial that generates the CRC value (CRC-16)
"X 16 +X 15 +X 2 +1".
-[CRC(P) (S) (D) (N)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (S) | The device start number storing the data of CRC value generated objects | - | Signed BIN16 | ANY16 |
| (D) | The destination device number of the generated CRC value | - | Signed BIN16 | ANY16 |
| (N) | The number of 8-bit data (bytes) for calculating the CRC value or the number of the device storing the number of data | 1 to 256 | Unsigned BIN16 | ANY16_U |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | ||||||||||
| KnX | KnY | KnM | KnS | T | C | D | R | SD | K | H | [D] | XXP | ||
| CRC | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||
| Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||||
| Parameter 3 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||
Features
Start with the device specified in (S), generate the CRC value of 8-bit data (byte unit) at (N) point, and store it in (D).
The mode used by this instruction in calculation includes 16-bit conversion mode and 8-bit conversion mode. For the operation of each mode, please refer to the following content.
1. 16-bit conversion mode (when SM161=OFF)
Calculate the upper 8 bits (byte) and lower 8 bits (byte) of the (S) device. The result is stored in 16 bits of 1 point of the device specified in (D). In the case of the following program, perform the conversion as shown below.

| Example (s)=D100, (d)=D0, (n)=6 | |||||
| Devices | Content of object data | ||||
| 8-bit | 16-bit | ||||
| CRC value generation target data storage destination | (s) | Low byte | D100 low | 01H | 0301H |
| High byte | D100 high | 03H | |||
| (s)+1 | Low byte | D101 low | 03H | 0203H | |
| High byte | D101 high | 02H | |||
| (s)+2 | Low byte | D102 low | 00H | 1400H | |
| High byte | D102 high | 14H | |||
| ... | | | |||
| (S)+(N)/2-1 | Low byte | | |||
| High byte | |||||
| CRC value storage target | (d) | Low byte | D0 low | E4H | 41E4H |
| High byte | D0 high | 41H | |||
2. 8-bit conversion mode (when SM8161=ON)
In 8-bit conversion mode, only the lower 8 bits (lower byte) of the (s) device are operated on. As a result, 2 points are used starting from the device specified in (d), the lower 8 bits (bytes) are stored in (d), and the upper 8 bits (bytes) are stored in (d)+1.
In the case of the following program, perform the conversion as shown below.

| Example) (s)=D100, (d)=D0, (n)=6 | ||||
| Devices | Content of object data | |||
| CRC value generation target data storage destination | (s) | Low byte | D100 low | 01H |
| (s)+1 | Low byte | D101 low | 03H | |
| (s)+2 | Low byte | D102 low | 03H | |
| (s)+3 | Low byte | D103 low | 02H | |
| (s)+4 | Low byte | D104 low | 00H | |
| (s)+5 | Low byte | D105 low | 14H | |
| ... | | |||
| (S)+(N)-1 | Low byte | | ||
| CRC value storage target | (d) | Low byte | D0 | E4H |
| (d)+1 | Low byte | D1 | 41H | |
In the CRC(P) instruction, the generator polynomial of the CRC value (CRC-16) uses "X16+X15+X2+1", but there are also many standardized generator polynomials for the CRC value. If the generator polynomial is different, it will become a completely different CRC value, which should be noted. The main CRC value generator polynomials are shown below.
| Name | Generator polynomial |
| CRC-12 | X12+X11+X3+X2+X+1 |
| CRC-16 | X16+X15+X2+1 |
| CRC-32 | X32+X26+X23+X22+X16+X12+X11+X10+X8+X7+X5+X4+X2+X+1 |
| CRC-CCITT | X16+X12+X5+1 |
✎Note:
When (s1) use KnX, KnY, KnM, KnS, n must be specified as 4.
Error code
| Error code | Content |
| 4084H | The range of (N) exceeds 1 to 256 |
| 4085H | The data address of (S) to be converted exceeds the device range |
| 4086H | The (D) write address exceeds the device range |
| 4087H | Unsupported device type is used by (S) and (D) |
Example
1. 16-bit conversion mode

2. 8-bit conversion mode

CRC-XMODEM/cyclic redundancy check instruction
CRC-XMODEM(P)
The device specified in (s) is used as the start, and the CRC value of 8-bit data (byte units) at point (n) is generated and stored in (d)
PLC Editor2 version that supports this command: 2.3.1 and above
-[CRC-XMODEM(P) (s) (d) (n)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (s) | The device start number storing the data of CRC-XMODEM value generated objects | - | Signed BIN16 | ANY16 |
| (d) | The destination device number of the generated CRC-XMODEM value | - | Signed BIN16 | ANY16 |
| (n) | The number of 8-bit data (bytes) for calculating the CRC-XMODEM value or the number of the device storing the number of data | 1 to 256 | Unsigned BIN16 | ANY16_U |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | ||||||||||||||||||||||||||
| X | Y | M | S | SM | T(bit) | C(bit) | LC(bit) | HSC(bit) | D.b | KnX | KnY | KnM | KnS | T | C | D | R | SD | LC | HSC | K | H | E | [D] | XXP | |||||
| CRC-XMODEM | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||||||||||||||||||
| Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||||||||||||||||||||
| Parameter 3 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||||||||||||||||||
Features
CRC-XMODEM (Cyclic Redundancy Check-XMODEM, abbreviation: CRC-XMODEM) is one of the error checking methods used in communication. In addition to CRC-XMODEM, there are also parity and checksum (checksum) error checking methods, and the CCD (P) instruction can be used to calculate the horizontal parity and checksum values.
The polynomial for generating the CRC-XMODEM value (CRC-CCITT) in this command uses "X16+X12+X5+1"
The modes used in this instruction for calculation are 16-bit conversion mode and 8-bit conversion mode. For the action of each mode, please refer to the following.
(1) 16-bit conversion mode (when SM161=OFF)
The high 8 bits (bytes) and low 8 bits (bytes) of the device in (s) are operated. The result is stored to the 16 bits of the soft element 1 point specified in (d).
In the case of the following program, the conversion is executed as follows

| CRC-XMODEM 16-bit mode | CRC value generation object data storage target | CRC value storage target | |||||||||||
| (s) | (s)+1 | (s)+2 | ... | (s)+(n)/2-1 | (d) | ||||||||
Low Byte | High Byte | Low Byte | High Byte | Low Byte | High Byte | Low Byte | High Byte | Low Byte | High Byte | ||||
| (s)=D100,(d)=D0,(n)=6 | Device | D100 low | D100 high | D101 low | D101 high | D102 low | D102 high | - | D0 low | D0 high | |||
| Contents of object data | 8-bit | 01H | 03H | 03H | 02H | 00H | 14H | 7BH | 0CH | ||||
| 16-bit | 0301H | 0203H | 1400H | 0C7BH | |||||||||
(1) 8-bit conversion mode (when SM161=ON)
In the 8-bit conversion mode, only the low 8 bits (low byte) of the device of (s) are operated. The result uses 2 points from the soft component specified in (d), storing the low 8 bits (bytes) in (d) and the high 8 bits (bytes) in (d) + 1.
In the case of the following program, the conversion is executed as follows

CRC-XMODEM 8-bit mode | CRC value generation object data storage target | CRC value storage target | |||||||||
| (s) | (s)+1 | (s)+2 | (s)+3 | (s)+4 | (s)+5 | ... | (s)+(n)-1 | (d) | (d)+1 | ||
Low Byte | Low Byte | Low Byte | Low Byte | Low Byte | Low Byte | Low Byte | Low Byte | Low Byte | |||
| (s)=D100,(d)=D0,(n)=6 | Device | D100 Low | D101 Low | D102 Low | D103 Low | D104 Low | D105 Low | - | D0 | D1 | |
| Contents of object data | 01H | 03H | 03H | 02H | 00H | 14H | 7BH | 0CH | |||
The CRC value (CRC-CCITT) in the CRC-XMODEM(P) instruction uses "X16+X12+X5+1" in the generating polynomial, but there are many standardized generating polynomials for CRC values. If this generating polynomial is different, it will become a completely different CRC value and should be noted. The main generating polynomials for CRC values are shown below.
| Name | Generator polynomial |
| CRC-12 | X12+X11+X3+X2+X+1 |
| CRC-16 | X16+X15+X2+1 |
| CRC-32 | X32+X26+X23+X22+X16+X12+X11+X10+X8+X7+X5+X4+X2+X+1 |
| CRC-CCITT | X16+X12+X5+1 |
Error code
| Error code | Content |
| 4084H | The range of (n) exceeds 1 to 256 |
| 4085H | The data address of (s) to be converted exceeds the device range |
| 4086H | The (d) write address exceeds the device range |
| 4087H | Unsupported device type is used by (s) and (d) |
Example
③16-bit conversion mode

④8-bit conversion mode

LRC/longitudinal redundancy check
LRC(P)
The device specified in (s) is used as the start, and the data to be checked (2n characters) is summed two by two into a hexadecimal value and stored in (d).
PLC Editor2 version that supports this command: 2.3.1 and above
-[LRC(P) (s) (d) (n)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (s) | The device start number storing the data of LRC value generated objects | - | Signed BIN16 | ANY16 |
| (d) | The destination device number of the generated LRC value | - | Signed BIN16 | ANY16 |
| (n) | The number of 8-bit data (bytes) for calculating the LRC value or the number of the device storing the number of data | 1 to 256 | Unsigned BIN16 | ANY16_U |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | |||||||||||||||||||||||
| X | Y | M | S | SM | T(bit) | C(bit) | LC(bit) | HSC(bit) | D.b | KnX | KnY | KnM | KnS | T | C | D | R | SD | LC | HSC | K | H | E | [D] | XXP | ||
| LRC | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | |||||||||||||||
| Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | |||||||||||||||||
| Parameter 3 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | |||||||||||||||
Features
Longitudinal Redundancy Check (LRC) is a common form of checksum used in communications, also known as LRC checksum or longitudinal checksum. It is an error detection method that generates check bits from a specific bit string on a vertical channel. LRC is often used in conjunction with VRC in the row and column format, so that for each character check digit.
The specific algorithm is as follows.
(1) Sum the data to be verified (2n characters) two by two to form a hexadecimal value.
(2) Modulo the summation result with 256.
(3) the resulting modulus is subtracted from 256 to get the result of the checksum (another method: the modulus is inverted by bit and then added to 1).
Example of hexadecimal data: 01 A0 7C FF 02
(Hexadecimal calculation)
Summation: 01 + A0 + 7C + FF + 02 = 21E Modulo: 21E % 100 = 1E Calculation: 100 - 1E = E2
(Calculated in decimal)
Summation: 01 + 160 + 124 + 255 + 02 = 542 Modulo: 542 % 256 = 30 Calculation: 256 - 30 = 226
The modes used in this instruction for calculation are 16-bit conversion mode and 8-bit conversion mode. For more information on the actions of each mode, see the following section.
(1) 16-bit conversion mode (when SM161=OFF)
The high 8 bits (bytes) and low 8 bits (bytes) of the device in (s) are operated. The result is stored to the 16 bits of the device 1 point specified in (d).
In the case of the following program, the conversion is executed as follows

| LRC 16-bit mode | LRC value generation object data storage target | LRC value storage target | |||||||||||
| (s) | (s)+1 | (s)+2 | ... | (s)+(n)/2-1 | (d) | ||||||||
| D100 | D101 | D102 | D(s)+(n)/2-1 | D0 | |||||||||
| (s)=D100,(d)=D0,(n)=6 | Device | Low Byte | High Byte | Low Byte | High Byte | Low Byte | High Byte | Low Byte | High Byte | Low Byte | High Byte | ||
| Contents of object data | 8-bit | 01H | 03H | 03H | 02H | 00H | 14H | E3H | 00H | ||||
| 16-bit | 0301H | 0203H | 1400H | 00E3H | |||||||||
(1) 8-bit conversion mode (when SM161=ON)
In the 8-bit conversion mode, only the low 8 bits (low byte) of the device of (s) are operated. The result uses 2 points from the soft component specified in (d), storing the low 8 bits (bytes) in (d) and the high 8 bits (bytes) in (d) + 1.
In the case of the following program, the conversion is executed as follows

| LRC 8-bit mode | LRC value generation object data storage target | LRC value storage target | |||||||||
| (s) | (s)+1 | (s)+2 | (s)+3 | (s)+4 | (s)+5 | ... | (s)+(n)-1 | (d) | (d)+1 | ||
Low Byte | Low Byte | Low Byte | Low Byte | Low Byte | Low Byte | Low Byte | Low Byte | Low Byte | |||
| (s)=D100,(d)=D0,(n)=6 | Device | D100 Low | D101 Low | D102 Low | D103 Low | D104 Low | D105 Low | É | É | D0 | D1 |
| Contents of object data | 01H | 03H | 03H | 02H | 00H | 14H | E3H | 00H | |||
✎Note:
When (s1) use KnX, KnY, KnM, KnS, n must be specified as 4.
Error code
| Error code | Content |
| 4084H | The range of (n) exceeds 1 to 256 |
| 4085H | The data address of (s) to be converted exceeds the device range |
| 4086H | The (d) write address exceeds the device range |
| 4087H | Unsupported device type is used by (s) and (d) |
Example
⑤16-bit conversion mode

LRC operation is performed on the high 8 bits (bytes) and low 8 bits (bytes) of the 6 device starting at (D100). The result is stored to the 16 bits of the (D0) soft component.
⑥8-bit conversion mode

The low 8 bits (low byte) of the 6 device from (D100) are operated. The result uses 2 points from (D0) designated device, and stores the low 8 bits (bytes) in (D0) and the high 8 bits (bytes) in (D1).
STDEV/BIN 16-bit sample standard deviation
STDEV(P)
The standard deviation of the (n) points (16-bit data units) starting from the device specified in (s1) is calculated, and the result of the calculation is stored in (d) by rounding.
PLC Editor2 version that supports this command: 2.3.1 and above
-[STDEV(P) (s1) (d) (n)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (s1) | Device start number of the data for standard deviation calculation. | - | Signed BIN16 | ANY16 |
| (d) | Device start number for storing standard deviation. | - | Signed BIN16 | ANY16 |
| (n) | Number of data or device number where the number of data is stored. | 2 to 32767 | Signed BIN16 | ANY16 |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | |||||||||||||||||||||||
| X | Y | M | S | SM | T(bit) | C(bit) | LC(bit) | HSC(bit) | D.b | KnX | KnY | KnM | KnS | T | C | D | R | SD | LC | HSC | K | H | E | [D] | XXP | ||
| STDEV | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | |||||||||||||||
| Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | |||||||||||||||||
| Parameter 3 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||||||||||||||
Error code
| Error code | Content |
| 4084H | The range of (n) exceeds 2 to 32767 |
| 4085H | The data address of (s) (n) to be converted exceeds the device range |
| 4086H | The (d) write address exceeds the device range |

The standard deviation of the 5 device (16-bit data units) starting from the device specified in (D1) is calculated, and the result of the calculation is stored in (D10).
DSTDEV/BIN 32-bit sample standard deviation
DSTDEV(P)
The standard deviation of the (n) points (32-bit data units) starting from the device specified in (s1) is calculated, and the result of the calculation is stored in (d) by rounding.
PLC Editor2 version that supports this command: 2.3.1 and above
-[DSTDEV(P) (s1) (d) (n)]
Content, range and data type
| Parameter | Content | Range | Data type | Data type (label) |
| (s1) | Device start number of the data for standard deviation calculation. | - | Signed BIN32 | ANY32 |
| (d) | Device start number for storing standard deviation. | - | Signed BIN32 | ANY32 |
| (n) | Number of data or device number where the number of data is stored. | 1 to 2147483647 | Signed BIN32 | ANY32 |
Device used
| Instruction | Parameter | Devices | Offset modification | Pulse extension | |||||||||||||||||||||||
| X | Y | M | S | SM | T(bit) | C(bit) | LC (bit) | HSC (bit) | D.b | KnX | KnY | KnM | KnS | T | C | D | R | SD | LC | HSC | K | H | E | [D] | XXP | ||
| DSTDEV | Parameter 1 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | |||||||||||||||
| Parameter 2 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | |||||||||||||||||
| Parameter 3 | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ||||||||||||||
Error code
| Error code | Content |
| 4084H | The range of (n) exceeds 1 to 2147483647 |
| 4085H | The data address of (s) (n) to be converted exceeds the device range |
| 4086H | The (d) write address exceeds the device range |

The standard deviation of the 5 device (16-bit data units) starting from the device specified in (D1,D2) is calculated, and the result of the calculation is stored in (D20,D21)